<template>
	<view class="content">
		<view class="searchTopDFat">
			<view class="searchTop">
				<view class="searchTop_local">
					乌鲁木齐市
				</view>
				<view class="searchToped">
					<u-search placeholder="搜索" v-model="keywords" bg-color="#ffffff" :showIcon="true">
					</u-search>
				</view>
			</view>
		</view>

		<view class="topMessage">
			<view class="carState">
				<view class="carState_content">
					<view class="carState_content_l">
						<view class="carState_l_t">
							宝马i8 <u-icon name="arrow-right"></u-icon>
						</view>
						<view class="carState_l_b">
							<image src="../../static/images/peogress.png" mode="" class="imgSoned"></image> 51000km
						</view>
					</view>
					<view class="carState_content_r">
						<image src="../../static/images/dd2.jpg" class="carState_img" mode=""></image>
						<view class="carState_txt">
							浙B17777
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="carScrollfat">
			<view class="carScroll">
				<scrollx></scrollx>
			</view>
		</view>
		<view class="centerContent">
			<view class="centerContent_title">
				方便快速选择您想要购买的商品及服务
			</view>
			<view class="centetContent">
				<view class="centetContentSon" v-for="(item,index) in listImages" :key="index" @click="getState(item)">
					<view class="centetContentSons" :class="{'centetContentactived':item.state}">

						<view class="centetContentSon_t" v-if="item.state">
							<image :src="item.image1" class="centetContentIg"></image>
						</view>
						<view class="centetContentSon_t" v-else>
							<image :src="item.image" class="centetContentIg"></image>
						</view>
						<view class="centetContentSon_b">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
			<view class="centerContent_bottom">
				<view class="btnsend">
					已选{{stateNum}}项 查看详情
				</view>
			</view>
		</view>
		<view class="recommended">
			<view class="recommenSon">
				<view class="titImage">
					<view class="titImage_img">
						<image class="titImage_g" src="../../static/images/dd2.jpg" mode=""></image>
					</view>
					<view class="titText">
						<view class="titText_l">
							宝马i8车主最常选择这些保养项
						</view>
						<view class="titText_r">
							没经验?跟着推荐买!
						</view>
					</view>
				</view>
				<view class="titBon">
					<view class="titBonson">
						<view class="sons">
							<view class="sonsone">
								<image class="sonsoneimg" src="../../static/images/dd2.jpg" mode=""></image>
							</view>
							<view class="sonsonetwo">
								<view class="sonsonetwoson">
									立减300赠油折
								</view>
							</view>
							<view class="sonsonethree">
								减震＆悬挂
							</view>
						</view>
						<view class="sons">
							<view class="sonsone">
								<image class="sonsoneimg" src="../../static/images/dd2.jpg" mode=""></image>
							</view>
							<view class="sonsonetwo">
								<view class="sonsonetwoson">
									立减300赠油折
								</view>
							</view>
							<view class="sonsonethree">
								减震＆悬挂
							</view>
						</view>
						<view class="sons">
							<view class="sonsone">
								<image class="sonsoneimg" src="../../static/images/dd2.jpg" mode=""></image>
							</view>
							<view class="sonsonetwo">
								<view class="sonsonetwoson">
									立减300赠油折
								</view>
							</view>
							<view class="sonsonethree">
								减震＆悬挂
							</view>
						</view>
						<view class="sons">
							<view class="sonsone">
								<image class="sonsoneimg" src="../../static/images/dd2.jpg" mode=""></image>
							</view>
							<view class="sonsonetwo">
								<view class="sonsonetwoson">
									立减300赠油折
								</view>
							</view>
							<view class="sonsonethree">
								减震＆悬挂
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="clearCard">
			<seckill></seckill>
		</view>
		<view class="clearCard">
			<clearcar></clearcar>
		</view>
		<view class="activeHover">
			<view class="activeHover_son">
				<image class="son_image" src="../../static/images/dd2.jpg" mode=""></image>
			</view>
			<view class="activeHover_son">
				<image class="son_image" src="../../static/images/dd2.jpg" mode=""></image>
			</view>
		</view>
		<view class="likeFoot">
			<image src="../../static/images/title_like.png" class="titleed"></image>
		</view>
		<view class="likeFootBob">
			<productlist></productlist>
		</view>
	</view>
</template>

<script>
	import scrollx from "../../component/scrollx.vue"
	import clearcar from "../../component/clearcar.vue"
	import seckill from "../../component/seckill.vue"
	import productlist from "../../component/productlist.vue"
	export default {
		data() {
			return {
				// 选中项数量
				stateNum: 0,
				keywords: '',
				listImages: [{
					name: '机油/润滑油',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '机油滤清器',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '空气滤清器',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '空调滤清器',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '空调冷却剂',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '防冻液',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '火花塞',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '雾灯',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '发动机养护',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}, {
					name: '刹车油',
					image: '../../static/images/my_list_heart.png',
					image1: '../../static/images/peogress.png',
					state: false
				}],
				// 选中项的 id 数组
				listImagesActive: [],
			}
		},
		components: {
			scrollx,
			clearcar,
			seckill,
			productlist
		},
		onLoad() {},
		methods: {
			getState(e) {
				e.state = !e.state
				var stated = e.state
				if (stated) {
					this.listImages.forEach(x => {
						if (x.state == true) {
							// 点击添加到 已选中项数组 里面
							this.listImagesActive.push(x.name)
						}
					})
					this.listImagesActive = [...new Set(this.listImagesActive)]
				} else {
					this.listImagesActive.forEach((x, index) => {
						if (x == e.name) {
							this.listImagesActive.splice(index, 1)
						}
						// 已选中项数组 信息
						console.log(this.listImagesActive)
					})
				}
				this.stateNum = this.listImagesActive.length
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background-color: #f0f0f0;
		padding-top: 180rpx;

		.searchTopDFat {
			padding: 70rpx 24rpx 0 24rpx;
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			z-index: 999;
			height: 180rpx;
			width: 100%;
			display: flex;
			justify-content: flex-end;
			background-color: #f0f0f0;
		}

		.searchTop {
			width: 100%;
			height: 100rpx;
			display: flex;
			align-items: center;

			.searchTop_local {
				display: flex;
				height: 30rpx;
				justify-content: center;
				align-items: center;
				font-size: 22rpx;
				color: #000000;
			}

			.searchToped {
				margin-left: 10rpx;
			}
		}

		.topMessage {
			width: 100%;
			box-sizing: border-box;

			.carState {
				width: 100%;
				padding: 0 12rpx 15rpx 12rpx;
				box-sizing: border-box;

				.carState_content {
					display: flex;
					align-items: center;
					justify-content: space-between;
					width: 100%;
					padding: 10rpx 20rpx;
					background-color: #FFFFFF;
					border-radius: 10rpx;
					color: #000000;
					box-sizing: border-box;

					.carState_content_l {
						display: flex;
						flex-direction: column;

						.carState_l_t {
							font-size: 29rpx;
							margin-bottom: 15rpx;
						}

						.carState_l_b {
							display: flex;
							align-items: center;
							font-size: 24rpx;

							.imgSoned {
								width: 40rpx;
								height: 40rpx;
							}
						}
					}

					.carState_content_r {
						display: flex;
						align-items: center;
						justify-content: space-around;
						flex-direction: column;

						.carState_img {
							width: 165rpx;
							height: 65rpx;
							margin-bottom: 15rpx;
						}

						.carState_txt {
							height: 30rpx;
							font-size: 19rpx;
						}
					}
				}
			}


		}

		.carScrollfat {
			width: 100%;
			padding: 0 12rpx;
			box-sizing: border-box;
			margin-bottom: 20rpx;

			.carScroll {
				width: 100%;
				background-color: #ffffff;
				border-radius: 10rpx;
				padding: 40rpx 20rpx;
				box-sizing: border-box;
			}
		}

		.centerContent {
			width: 100%;
			background-color: #FFFFFF;
			padding: 0 10rpx;

			.centerContent_title {
				width: 100%;
				height: 105rpx;
				font-size: 30rpx;
				font-weight: 600;
				color: #ff2401;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.centetContent {
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.centetContentSon {
					width: 19%;
					height: 175rpx;
					color: #3c3c3c;
					box-sizing: border-box;
					font-size: 21rpx;
					margin-top: 10rpx;

					.centetContentSons {
						display: flex;
						align-items: center;
						flex-direction: column;
						justify-content: flex-end;
						width: 100%;
						height: 100%;
						padding-bottom: 15rpx;
						background-color: #f5f5f5;
						border-radius: 15rpx;
						color: #3c3c3c;
					}

					.centetContentactived {
						position: relative;
						background-image: linear-gradient(to bottom, #ff5e2d, #ff2401);
						color: #FFFFFF
					}

					.centetContentactived::after {
						position: absolute;
						top: 8rpx;
						right: 10rpx;
						content: '';
						background: url(../../static/images/rights.png) no-repeat;
						width: 29rpx;
						height: 29rpx;
						background-size: 100% 100%;

					}

					.centetContentSon_t {
						.centetContentIg {
							width: 70rpx;
							height: 70rpx;
						}
					}

					.centetContentSon_b {
						width: 100%;
						margin-top: 15rpx;
						text-align: center;
						font-size: 22rpx;
					}
				}
			}

			.centerContent_bottom {
				height: 120rpx;
				display: flex;
				align-items: center;
				width: 100%;
				padding: 10rpx 45rpx;

				.btnsend {
					width: 100%;
					height: 85rpx;
					font-size: 29rpx;
					color: #ff7c67;
					border: 1rpx solid #ff7c67;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 43rpx;
					font-weight: 600;
				}
			}
		}

		.recommended {
			height: 525rpx;
			width: 100%;
			padding: 15rpx 15rpx 0 15rpx;
			box-sizing: border-box;

			.recommenSon {
				padding: 15rpx;
				width: 100%;
				height: 100%;
				background-color: #FFFFFF;
				border-radius: 10rpx;

				.titImage {
					display: flex;
					height: 220rpx;
					align-items: center;
					width: 100%;
					justify-content: space-between;

					.titImage_img {
						width: 390rpx;
						height: 190rpx;

						.titImage_g {
							width: 100%;
							height: 100%;
						}
					}

					.titText {
						width: 270rpx;
						display: flex;
						flex-direction: column;

						.titText_l {
							font-size: 29rpx;
							font-weight: 600;
						}

						.titText_r {
							font-size: 24rpx;
						}
					}
				}

				.titBon {
					height: 235rpx;
					width: 100%;
					padding: 0 10rpx;

					.titBonson {
						display: flex;
						align-items: center;
						justify-content: space-around;
						width: 100%;
						height: 100%;

						.sons {
							background-color: #f8f8f8;
							width: 150rpx;
							height: 100%;
							margin: 0 10rpx;
							display: flex;
							flex-direction: column;
							border-radius: 10rpx;
							overflow: hidden;

							.sonsone {
								width: 100%;
								height: 145rpx;

								.sonsoneimg {
									width: 100%;
									height: 100%;
								}
							}

							.sonsonetwo {
								padding: 9rpx;

								.sonsonetwoson {
									width: 100%;
									height: 32rpx;
									font-size: 18rpx;
									background-color: #ff1106;
									color: #FFFFFF;
									display: flex;
									align-items: center;
									justify-content: center;
									border-top-left-radius: 15rpx;
									border-bottom-right-radius: 15rpx;
								}
							}

							.sonsonethree {
								color: #010101;
								font-size: 18rpx;
								width: 100%;
								height: 26rpx;
								display: flex;
								justify-content: center;
								align-items: center;
							}
						}
					}
				}
			}
		}

		.clearCard {
			width: 100%;
			height: 330rpx;
			padding: 0 15rpx;
			box-sizing: border-box;
		}

		.activeHover {
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			height: 205rpx;
			padding: 15rpx;
			background-color: #f0f0f0;
			box-sizing: border-box;

			.activeHover_son {
				width: 355rpx;
				height: 180rpx;
				border-radius: 15rpx;
				overflow: hidden;

				.son_image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.likeFoot {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 95rpx;

			.titleed {
				width: 386rpx;
				height: 30rpx;
			}
		}

		.likeFootBob {
			width: 100%;
		}
	}
</style>
